package com.umakr.ax.app.web;


import com.baomidou.mybatisplus.plugins.Page;
import com.umakr.ax.app.service.WechatAccountErrorLogWebService;
import com.umakr.ax.common.model.WechatAccountErrorLog;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 微信公众号第三方平台全网发布
 *
 * @author Wmdz
 * @since 2018-01-03
 */
@Controller
@RequestMapping("/api/web/wechat/wechataccounterrorlog")
public class WechatAccountErrorLogWebController extends AbstractController {

    @Autowired
    WechatAccountErrorLogWebService wechatAccountErrorLogWebService;

    /**
     * 读取列表
     *
     */
    @ApiOperation(value = "读取公众号信息异常列表")
    @GetMapping(value = "/list")
    public Object list(ModelMap modelMap, @RequestParam Map<String, Object> param) {
        Page<WechatAccountErrorLog> data = wechatAccountErrorLogWebService.list(param);
        return setSuccessModelMap(modelMap, data);
    }


    /**
     * 记录保存
     *
     */
    @ApiOperation(value = "保存公众号信息异常记录")
    @PostMapping(value = "/save")
    public Object save(ModelMap modelMap, @RequestParam Map<String, Object> param) {
        Map data = wechatAccountErrorLogWebService.save(param);
        return setSuccessModelMap(modelMap, data);
    }

    /**
     * 记录处理
     *
     */
    @ApiOperation(value = "处理公众号信息异常")
    @PostMapping(value = "/handle")
    public Object handle(ModelMap modelMap, @RequestParam Map<String, Object> param) {
        return setSuccessModelMap(modelMap, wechatAccountErrorLogWebService.handle(param));
    }

    /**
     * 记录告警
     *
     */
    @ApiOperation(value = "告警公众号信息异常 发送短信通知")
    @PostMapping(value = "/warning")
    public Object warning(ModelMap modelMap, @RequestParam Map<String, Object> param) {
        return setSuccessModelMap(modelMap, wechatAccountErrorLogWebService.warning(param));
    }
}